/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package gsoc.ogsadai.model.provider;

import gsoc.ogsadai.model.util.ModelAdapterFactory;

import java.util.ArrayList;
import java.util.Collection;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;

import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;

/**
 * This is the factory that is used to provide the interfaces needed to support Viewers.
 * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
 * The adapters also support Eclipse property sheets.
 * Note that most of the adapters are shared among multiple instances.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class ModelItemProviderAdapterFactory extends ModelAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
	/**
	 * This keeps track of the root adapter factory that delegates to this adapter factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComposedAdapterFactory parentAdapterFactory;

	/**
	 * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IChangeNotifier changeNotifier = new ChangeNotifier();

	/**
	 * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Collection<Object> supportedTypes = new ArrayList<Object>();

	/**
	 * This constructs an instance.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ModelItemProviderAdapterFactory() {
		supportedTypes.add(IEditingDomainItemProvider.class);
		supportedTypes.add(IStructuredItemContentProvider.class);
		supportedTypes.add(ITreeItemContentProvider.class);
		supportedTypes.add(IItemLabelProvider.class);
		supportedTypes.add(IItemPropertySource.class);
	}

	/**
	 * This keeps track of the one adapter used for all {@link gsoc.ogsadai.model.ActivityType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ActivityTypeItemProvider activityTypeItemProvider;

	/**
	 * This creates an adapter for a {@link gsoc.ogsadai.model.ActivityType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createActivityTypeAdapter() {
		if (activityTypeItemProvider == null) {
			activityTypeItemProvider = new ActivityTypeItemProvider(this);
		}

		return activityTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link gsoc.ogsadai.model.DataType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DataTypeItemProvider dataTypeItemProvider;

	/**
	 * This creates an adapter for a {@link gsoc.ogsadai.model.DataType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createDataTypeAdapter() {
		if (dataTypeItemProvider == null) {
			dataTypeItemProvider = new DataTypeItemProvider(this);
		}

		return dataTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link gsoc.ogsadai.model.DocumentRoot} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DocumentRootItemProvider documentRootItemProvider;

	/**
	 * This creates an adapter for a {@link gsoc.ogsadai.model.DocumentRoot}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createDocumentRootAdapter() {
		if (documentRootItemProvider == null) {
			documentRootItemProvider = new DocumentRootItemProvider(this);
		}

		return documentRootItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link gsoc.ogsadai.model.InputStreamType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InputStreamTypeItemProvider inputStreamTypeItemProvider;

	/**
	 * This creates an adapter for a {@link gsoc.ogsadai.model.InputStreamType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createInputStreamTypeAdapter() {
		if (inputStreamTypeItemProvider == null) {
			inputStreamTypeItemProvider = new InputStreamTypeItemProvider(this);
		}

		return inputStreamTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link gsoc.ogsadai.model.InputType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InputTypeItemProvider inputTypeItemProvider;

	/**
	 * This creates an adapter for a {@link gsoc.ogsadai.model.InputType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createInputTypeAdapter() {
		if (inputTypeItemProvider == null) {
			inputTypeItemProvider = new InputTypeItemProvider(this);
		}

		return inputTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link gsoc.ogsadai.model.InputsType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InputsTypeItemProvider inputsTypeItemProvider;

	/**
	 * This creates an adapter for a {@link gsoc.ogsadai.model.InputsType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createInputsTypeAdapter() {
		if (inputsTypeItemProvider == null) {
			inputsTypeItemProvider = new InputsTypeItemProvider(this);
		}

		return inputsTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link gsoc.ogsadai.model.ListBeginType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ListBeginTypeItemProvider listBeginTypeItemProvider;

	/**
	 * This creates an adapter for a {@link gsoc.ogsadai.model.ListBeginType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createListBeginTypeAdapter() {
		if (listBeginTypeItemProvider == null) {
			listBeginTypeItemProvider = new ListBeginTypeItemProvider(this);
		}

		return listBeginTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link gsoc.ogsadai.model.ListEndType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ListEndTypeItemProvider listEndTypeItemProvider;

	/**
	 * This creates an adapter for a {@link gsoc.ogsadai.model.ListEndType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createListEndTypeAdapter() {
		if (listEndTypeItemProvider == null) {
			listEndTypeItemProvider = new ListEndTypeItemProvider(this);
		}

		return listEndTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link gsoc.ogsadai.model.OutputStreamType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected OutputStreamTypeItemProvider outputStreamTypeItemProvider;

	/**
	 * This creates an adapter for a {@link gsoc.ogsadai.model.OutputStreamType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createOutputStreamTypeAdapter() {
		if (outputStreamTypeItemProvider == null) {
			outputStreamTypeItemProvider = new OutputStreamTypeItemProvider(this);
		}

		return outputStreamTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link gsoc.ogsadai.model.OutputsType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected OutputsTypeItemProvider outputsTypeItemProvider;

	/**
	 * This creates an adapter for a {@link gsoc.ogsadai.model.OutputsType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createOutputsTypeAdapter() {
		if (outputsTypeItemProvider == null) {
			outputsTypeItemProvider = new OutputsTypeItemProvider(this);
		}

		return outputsTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link gsoc.ogsadai.model.ParallelType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ParallelTypeItemProvider parallelTypeItemProvider;

	/**
	 * This creates an adapter for a {@link gsoc.ogsadai.model.ParallelType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createParallelTypeAdapter() {
		if (parallelTypeItemProvider == null) {
			parallelTypeItemProvider = new ParallelTypeItemProvider(this);
		}

		return parallelTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link gsoc.ogsadai.model.PipelineType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PipelineTypeItemProvider pipelineTypeItemProvider;

	/**
	 * This creates an adapter for a {@link gsoc.ogsadai.model.PipelineType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createPipelineTypeAdapter() {
		if (pipelineTypeItemProvider == null) {
			pipelineTypeItemProvider = new PipelineTypeItemProvider(this);
		}

		return pipelineTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link gsoc.ogsadai.model.RequestType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RequestTypeItemProvider requestTypeItemProvider;

	/**
	 * This creates an adapter for a {@link gsoc.ogsadai.model.RequestType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createRequestTypeAdapter() {
		if (requestTypeItemProvider == null) {
			requestTypeItemProvider = new RequestTypeItemProvider(this);
		}

		return requestTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link gsoc.ogsadai.model.SequenceType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SequenceTypeItemProvider sequenceTypeItemProvider;

	/**
	 * This creates an adapter for a {@link gsoc.ogsadai.model.SequenceType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createSequenceTypeAdapter() {
		if (sequenceTypeItemProvider == null) {
			sequenceTypeItemProvider = new SequenceTypeItemProvider(this);
		}

		return sequenceTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link gsoc.ogsadai.model.WorkflowType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected WorkflowTypeItemProvider workflowTypeItemProvider;

	/**
	 * This creates an adapter for a {@link gsoc.ogsadai.model.WorkflowType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createWorkflowTypeAdapter() {
		if (workflowTypeItemProvider == null) {
			workflowTypeItemProvider = new WorkflowTypeItemProvider(this);
		}

		return workflowTypeItemProvider;
	}

	/**
	 * This returns the root adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComposeableAdapterFactory getRootAdapterFactory() {
		return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
	}

	/**
	 * This sets the composed adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
		this.parentAdapterFactory = parentAdapterFactory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean isFactoryForType(Object type) {
		return supportedTypes.contains(type) || super.isFactoryForType(type);
	}

	/**
	 * This implementation substitutes the factory itself as the key for the adapter.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter adapt(Notifier notifier, Object type) {
		return super.adapt(notifier, this);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object adapt(Object object, Object type) {
		if (isFactoryForType(type)) {
			Object adapter = super.adapt(object, type);
			if (!(type instanceof Class) || (((Class<?>)type).isInstance(adapter))) {
				return adapter;
			}
		}

		return null;
	}

	/**
	 * This adds a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void addListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.addListener(notifyChangedListener);
	}

	/**
	 * This removes a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void removeListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.removeListener(notifyChangedListener);
	}

	/**
	 * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void fireNotifyChanged(Notification notification) {
		changeNotifier.fireNotifyChanged(notification);

		if (parentAdapterFactory != null) {
			parentAdapterFactory.fireNotifyChanged(notification);
		}
	}

	/**
	 * This disposes all of the item providers created by this factory. 
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void dispose() {
		if (activityTypeItemProvider != null) activityTypeItemProvider.dispose();
		if (dataTypeItemProvider != null) dataTypeItemProvider.dispose();
		if (documentRootItemProvider != null) documentRootItemProvider.dispose();
		if (inputStreamTypeItemProvider != null) inputStreamTypeItemProvider.dispose();
		if (inputsTypeItemProvider != null) inputsTypeItemProvider.dispose();
		if (inputTypeItemProvider != null) inputTypeItemProvider.dispose();
		if (listBeginTypeItemProvider != null) listBeginTypeItemProvider.dispose();
		if (listEndTypeItemProvider != null) listEndTypeItemProvider.dispose();
		if (outputStreamTypeItemProvider != null) outputStreamTypeItemProvider.dispose();
		if (outputsTypeItemProvider != null) outputsTypeItemProvider.dispose();
		if (parallelTypeItemProvider != null) parallelTypeItemProvider.dispose();
		if (pipelineTypeItemProvider != null) pipelineTypeItemProvider.dispose();
		if (requestTypeItemProvider != null) requestTypeItemProvider.dispose();
		if (sequenceTypeItemProvider != null) sequenceTypeItemProvider.dispose();
		if (workflowTypeItemProvider != null) workflowTypeItemProvider.dispose();
	}

}
